package cn.edu.mju.dilidili.modules.reply.controller;

import cn.edu.mju.dilidili.modules.reply.entity.Reply;
import cn.edu.mju.dilidili.modules.reply.service.ReplyService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * 作用描述
 *
 * @author linzsh
 * @date 2022/9/24 1:56
 */
@RequiredArgsConstructor
@RestController
public class Hello {
    final ReplyService replyService;
    final RedisTemplate<String, String> redis;
    @RequestMapping("/hello")
    String hello() {
        return "hello world! I am reply application.";
    }

    @RequestMapping("/mysql")
    Reply mysql() {
        return replyService.getById(1);
    }

    @RequestMapping("/redis")
    String redis() {
        return Objects.requireNonNull(redis.opsForHash().get("hello", "reply")).toString();
    }
}
